module.exports.getCustomerByOpenId   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
dl 11
loc 11
rs 10
nop 1
1 View Code Duplication
const DB = require('../../libraries/db')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
const config = require('../../../config/config')
0 ignored issues
show
Unused Code introduced by
The constant config seems to be never used. Consider removing it.
Loading history...
3
const ModelBase = require('../../model/base')
4
const ApiError = require('../../util/api_error')
0 ignored issues
show
Unused Code introduced by
The constant ApiError seems to be never used. Consider removing it.
Loading history...
5
6
const table = 'mist_customer'
7
8
module.exports = {
9
    add: async function (data) {
10
        let res = await ModelBase.execInsert(table, data)
11
        return res;
12
    },
13
14
	getCustomerByOpenId: async function (openid) {
15
16
		let user = await DB.readMysql.first(
17
			'*'
18
		)
19
			.from(table)
20
			.where('openid', openid)
21
22
		return user
23
24
	},
25
26
	first: async function (customerId) {
27
28
		let user = await DB.readMysql.first(
29
			'*'
30
		)
31
			.from(table)
32
			.where('id', customerId)
33
34
		return user
35
36
	},
37
38
	edit: async function (data, where, notWhere = {}) {
39
		let result = await ModelBase.execUpdate(table, data, where, notWhere)
40
41
		return result
42
	}
43
44
}